package sunwul.hospital.hosp.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sunwul.hospital.common.result.Result;
import sunwul.hospital.hosp.service.ScheduleService;
import sunwul.hospital.model.model.hosp.Schedule;

import java.util.List;

/**
 * @author sunwul
 * @date 2023/11/9 22:31:51
 * @description
 */
@Api(tags = "医院排班信息管理")
@RestController
@RequestMapping("admin/hosp/hospital")
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    @ApiOperation(value = "根据医院编号与科室编号查询排班信息(分页)")
    @GetMapping("/getSchedule/{current}/{limit}/{hoscode}/{deptcode}")
    public Result getScheduleByPage(@PathVariable Long current,
                                    @PathVariable Long limit,
                                    @PathVariable String hoscode,
                                    @PathVariable String deptcode
                                    ){
        // TODO 暂时不做预约与排班规则,后期看页面改造
        Page<Schedule> result = scheduleService.getScheduleByPage(current,limit,hoscode,deptcode);
        return Result.ok(result);
    }

    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("/getScheduleDetail/{hoscode}/{deptcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String deptcode,
                                    @PathVariable String workDate){
        List<Schedule> schedules = scheduleService.getScheduleDetail(hoscode,deptcode,workDate);
        return Result.ok(schedules);
    }
}
